package fpt.edu.vn.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import fpt.edu.vn.dao.AddnewDao;
import fpt.edu.vn.model.Provinces;

/* 
 * DetailAction.java 
 *  
 * 0.1
 * 
 * 10/15/2012 
 *  
 * Copyright notice 
 *  
 * Modification Logs: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  -------------------------------------------------------- 
 *  15-Oct-2012  ThuongND    Create new 
 */
public class CheckAddShareTopicAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private String email;
	
	private String Username;
	public String getUsername() {
		return Username;
	}

	public void setUsername(String username) {
		Username = username;
	}

	private List<Provinces> lstProvince;

	public List<Provinces> getLstProvince() {
		return lstProvince;
	}

	public void setLstProvince(List<Provinces> lstProvince) {
		this.lstProvince = lstProvince;
	}

	private AddnewDao addnewdao = new AddnewDao();
	// For SessionAware
	Map<String, Object> session;

	public String execute() {
		String displayNamess="";
		session = ActionContext.getContext().getSession();
		email = (String) session.get("emailss");
		if (email != null) {
			displayNamess = (String) session.get("displayNamess");
			
			if ("".equals(displayNamess) || displayNamess == null) {
				setUsername(null);
			} else {
				setUsername(displayNamess);
			}
			
			//get district
			this.lstProvince = addnewdao.getProvince();
			return SUCCESS;
		} else {
			return ERROR;
		}

	}

	public Date getSysdate() {
		Date date = new Date();
		return date;
	}

	public String getStrDate() {
		String curdate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
				.format(Calendar.getInstance().getTime());
		return curdate;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

}
